﻿@using Ed.Entity
@using Ed.Web.Helpers
@model  List<Dictionary<string, object>>
@{
    Layout = null;
}
<!DOCTYPE html>
<!-- saved from url=(0095)http://m.iyuesao.com/MList/j3n2?sortName=CommentCount&sortOrder=DESC&shsj=2014-12-23-2015-01-17 -->
<html>
<head>
 <meta charset="utf-8">
    <title>雪绒花 - 登录页面</title>
    <link href="/Themes/default/home/css/index.css" rel="stylesheet" type="text/css">
    <link href="/Themes/default/home/css/login.css" rel="stylesheet" type="text/css">
    <link href="/Themes/default/lib/artDialog/css/ui-dialog.css" rel="stylesheet" />
    <link href="/Themes/default/lib/poshytip/tip-yellow/tip-yellow.css" rel="stylesheet" />
    <script src="/Themes/default/lib/jquery/jquery-1.11.1.js"></script>
    <script src="/Themes/default/lib/artDialog/dist/dialog-plus-min.js"></script>
    <script src="/Themes/default/lib/validate/jquery.validate.min.js"></script>
    <script src="/Themes/default/lib/validate/jquery.validate.extend.js"></script>
    <script src="/Themes/default/lib/validate/messages_cn.js"></script>
    <script src="/Themes/default/lib/cookie/jquery.cookie.js"></script>
    <script src="/Themes/default/lib/poshytip/jquery.poshytip.min.js"></script>
    <script src="/Themes/default/lib/function.js"></script>
    <script type="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>雪绒花</title>
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <meta name="baidu-site-verification" content="H6od0XC7DJ">
    <link rel="shortcut icon" href="http://m.iyuesao.com/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="/Content/css/xueronghua.3g.css">
    <script type="text/javascript">        //手机机型适配
        if (/Android (\d+\.\d+)/.test(navigator.userAgent)) {
            var version = parseFloat(RegExp.$1);
            if (version > 2.3) {
                var phoneScale = parseInt(window.screen.width) / 640;
                document.write('<meta name="viewport" content="width=640, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
            } else {
                document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
            }
        } else {
            document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
        }
    </script>
      <script type="text/javascript">
          $(function () {
              //表单验证
              $("#loginForm").validate({
                  rules: {
                      userName: {
                          rangelength: [5, 20]                       
                      }
                  },
                  userPassword: {
                      rangelength: [6, 20]                    
                  },
                  messages: {
                      userName: {
                          required: "用户名不能为空！",
                          rangelength: "用户名6-20位",
                          remote: "该用户名不存在！"
                      },
                      userPassword: {
                          required: "密码不能为空！",
                          rangelength: "密码长度必须在6-20之间",
                          remote: "密码错误！"
                      }
                  },
                  focusInvalid: true,
                  errorPlacement: function (error, element) {
                      var errorMsg = error[0].innerHTML;
                      var elementName = element[0].name;
                      $("#" + elementName).formtip(errorMsg);
                  },
                  success: function (element) {
                      var elem = $(element)[0].htmlFor;
                      $("#" + elem).poshytip('disable');
                      $("#" + elem).poshytip('destroy');
                  }
              });
              //登录
              do_login();
          });
          //登录提交
          function do_login() {
              $("#btnSubmit").click(function () {
                  //集成jquery validate   
                  if (!$("#loginForm").valid()) {
                      return false;
                  } else {
                      var userName = $.trim($("#userName").val());
                      var userPassword = $.trim($("#userPassword").val());
                      login_ajax(userName, userPassword);
                      return false;
                  }
              });
          }
          function login_ajax(userName, userPassword) {
              var url = "/Account/Login/DoLogin";
              var type = "normal";
              var accountType = get_account_type(userName);          
              var clientIp = "";             
              var clientPlace = "";
              var clientTime = get_client_time();
              var remember = false;
              //alert(remember);
              //alert("ok");
              $.ajax({
                  type: "post",
                  url: url,
                  data: { type: type, accountType: accountType, userName: userName, userPassword: userPassword, remember: remember, clientIp: clientIp, clientPlace: clientPlace, clientTime: clientTime },
                  dataType: "json",
                  beforeSend: function () {
                      showTopContentDialog("login_loding", "<div class='dialog_loading'>正在登录中，请稍后...</div>", "登陆提示", 400, 75);
                  },
                  complete: function () {
                  },
                  success: function (data) {
                      //console.log(data.Status);                   
                      if (data.Status) { //登录成功
                          top.dialog.list["login_loding"].close().remove();
                          //showMsg("登陆失败,请联系管理员！", "Error");
                          //showTopContentDialog("login_loding_error", "<div class='dialog_ok'>登陆成功,正在跳转中...</div>", "登陆成功", 400, 75);
                          showTopDialog("show_loading", "<div class='dialog_loading'>登陆成功,页面加载中，请稍后...</div>", "温馨提示", 400, 95);
                          setTimeout(function () {
                              top.dialog.list["login_loding_error"].close().remove();
                          }, 1000);
                          tiaozhuan();
                      } else {
                          top.dialog.list["login_loding"].close().remove();
                          //showMsg("登陆失败,请联系管理员！", "Error");
                          //showTopContentDialog("login_loding_error", "<div class='dialog_error'>登陆失败,用户名或密码错误！</div>", "登陆出错", 400, 75, false);
                          showTopContentDialog("login_loding_error", "<div class='dialog_error'>" + data.Msg + "</div>", "登录出错", 400, 75, false);
                          setTimeout(function () {
                              top.dialog.list["login_loding_error"].close().remove();
                          }, 1000);
                      }
                  },
                  error: function () {
                      top.dialog.list["login_loding"].close().remove();
                      //showMsg("登陆失败,请联系管理员！", "Error");
                      showTopContentDialog("login_loding_error", "<div class='dialog_error'>网络连接错误！</div>", "登录出错", 400, 75);
                      setTimeout(function () {
                          top.dialog.list["login_loding_error"].close().remove();
                      }, 1000);
                  }
              });
              //必须有这个组织表单提交
              return false;
          }
          function tiaozhuan() {
              var url = window.location.href;

//              if (url.indexOf("?ht") > 0) {
                  location.href = "/";
                  //                  location.href = "/Home/Main/Order/";       
//              }
//              else {
//                  location.href = "/Order/Order/KEHU/";
//              }
          }
          //根据用户名判断账号类型(username,email,phone)
          //var userName = "cyutyw@126.com"; 
          //var userName = "15225062328"; 
          function get_account_type(userName) {
              var reg_email = /^\w+@@[a-z0-9]+\.[a-z]+$/i;
              var reg_phone = /^[1]+[3,5]+\d{9}$/;
              if (reg_email.test(userName)) {
                  return "email";
              } else if (reg_phone.test(userName)) {
                  return "phone";
              } else {
                  return "username";
              }
          }
          //忘记密码
          function show_forget() {
              showTopWindow("show_forget", "/Account/Login/ForgetPassword", "找回密码", 600, 300, function () {
                  //alert("aaa");
              });
          }
    </script>
</head>
    <meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">
    <link href="css/scrollbar.css" rel="stylesheet">
</head>
<body>
    <header>
    <section class="title">雪绒花 登录</section>
    <!--<a class="return" href="javascript:history.go(-1)" title="返回"></a>
    <a class="screening" href="javascript:void(0)" title="筛选">筛选</a>-->
</header>
    <!--登录按钮的开始-->
    <div class="xrhdl">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="20%" align="right">
                    用户名：
                </td>
                <td width="80%">
                    <input id="userName" name="" type="text">
                </td>
            </tr>
            <tr>
                <td align="right">
                    密&nbsp;&nbsp;&nbsp;码：
                </td>
                <td>
                    <input id="userPassword" name="" type="text">
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input class="dlan" type="submit" value="立即登录">
                </td>
            </tr>
        </table>
    </div>
    <!--登录按钮的结束-->
</body>
</html>
